$(function() {
    var token = localStorage.token;
    function loadArea(pid) {
        $.ajax({
            type: "get",
            url: domain.test + "/getssx",
            data:{
                pid:pid
            },
            beforeSend: function(xhr) {
                xhr.setRequestHeader("token", token);
            },
            success: function (response) {
                console.log(response);
                if(response.data.rtnCode===200) {
                    var areaList = response.data.data;
                    if(areaList.length===0) {
                        localStorage.area = area;
                        localStorage.areaId = areaId;
                        console.log(areaId);
                        history.back();
                        return false;
                    }
                    console.log(areaList);
                    $(".areaList").html(template("areaList",{areaList:areaList}));
                }
            }
        });
    }
    loadArea("");
    var area = "";
    var areaId = "";
    $(".areaList").on("click",".areaItem",function(){
        area += $(this).attr("data-name") + " ";
        areaId += $(this).attr("data-pid") + " ";
        var pid = parseFloat($(this).attr("data-pid"));
        loadArea(pid);
    });
});